package edu.session;

import javax.print.MultiDocPrintService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

@WebServlet("/readSession")
public class ReadSession extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        

        Object user1 = session.getAttribute("user");
        if (user1 instanceof User) {
            PrintWriter writer = response.getWriter();
            User user = (User) user1;
            writer.write(user.getPassword() + "<br/>");
            writer.write(user.getUsername());

        }
        System.out.println(session.getMaxInactiveInterval());
    }
}
